#ifndef QREADJSON_H
#define QREADJSON_H

#include <QObject>
#include <QString>
#include <QFile>
#include <QIODevice>
#include <QJsonDocument>
#include <QJsonObject>




class QReadJson:public QObject
{
    Q_OBJECT
public:
    static QReadJson * GetInstance();



    /*Read Json*/
    //可以是2个参数。也可以是1个参数，1个参数必须为文件的全路径,2个必须路径分离
    static Q_INVOKABLE QString readFile(QString filePath,QString fileName = "");
    static QString jsonFileToStr(bool *result,QString *errorString,const QString &filePath);

    /*Write Json  To file*/
    static Q_INVOKABLE   bool writeFile(QString filePath,QString &data,QString fileName = "");
    static bool strToJsonFile(QString *errorString,const QString &filePath, const QString &data);

    static Q_INVOKABLE QString debug();


private:
    QReadJson();
    static QReadJson * instance;
    QString mError;
};

#endif // QREADJSON_H
